<script setup lang="ts">
import { computed, ref } from 'vue';

const firstName = ref('John')
const lastName = ref('Doe')

const fullName = computed({
  get(){
    return firstName.value + ' ' + lastName.value
  },
  set(value){
    const names = value.split(' ')
    firstName.value = names[0]
    lastName.value = names[1]
  }
})
</script>


<template>
 <input type="text" v-model="firstName">
 <input type="text" v-model="lastName">
 <p>完整姓名</p>
 <input type="text" v-model="fullName">
</template>